package com.tsinghuabigdata.edu.ddmath.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.tsinghuabigdata.edu.ddmath.R;
import com.tsinghuabigdata.edu.ddmath.bean.BensCourse;
import com.tsinghuabigdata.edu.ddmath.view.TagView;

import java.util.List;


/**
 * Created by Administrator on 2016/12/9.
 */

public class BeansCourseAdapter extends CommonAdapter<BensCourse> {

    private static final String TAG = "sky";

    public BeansCourseAdapter(Context context, List<BensCourse> mDatas) {
        super(context, mDatas);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.item_beans_course;
    }

    @Override
    protected void convert(ViewHolder helper, int position, BensCourse item) {
        String name;
        if ("九年级".equals(item.getGrade()) && "春季".equals(item.getTime())) {
            name = "中考数学" + item.getTime() + item.getKind() + "班";
        } else {
            name = item.getGrade() + "数学" + item.getTime() + item.getKind() + "班";
        }
        helper.setText(R.id.tv_course_name, name);
        helper.setText(R.id.tv_apply_count, item.getCount() + "人报名");
        helper.setText(R.id.tv_price, item.getPrice() + "");
        TextView tagTextView = helper.getView(R.id.tv_tag1);
        if (!TextUtils.isEmpty(item.getTag())) {
            tagTextView.setText(item.getTag());
            tagTextView.setVisibility(View.VISIBLE);
        } else {
            tagTextView.setVisibility(View.GONE);
        }
        if ("春季".equals(item.getTime())) {
            helper.setText(R.id.tv_date, "2月20日—6月18日");
        } else if ("暑期".equals(item.getTime())) {
            helper.setText(R.id.tv_date, "7月7日—8月20日");
        }
        TagView tagView = helper.getView(R.id.tag_view);
        if ("同步提分".equals(item.getKind())) {
            tagView.setColor1(mContext.getResources().getColor(R.color.tag1_color1));
            tagView.setColor2(mContext.getResources().getColor(R.color.tag1_color2));
            tagView.setColor3(mContext.getResources().getColor(R.color.tag1_color3));
            tagView.setContent("同步提分");
        } if ("衔接提分".equals(item.getKind())) {
            tagView.setColor1(mContext.getResources().getColor(R.color.tagadd_color1));
            tagView.setColor2(mContext.getResources().getColor(R.color.tagadd_color2));
            tagView.setColor3(mContext.getResources().getColor(R.color.tagadd_color3));
            tagView.setContent("衔接提分");
        }else if ("专题突破".equals(item.getKind())) {
            tagView.setColor1(mContext.getResources().getColor(R.color.tag2_color1));
            tagView.setColor2(mContext.getResources().getColor(R.color.tag2_color2));
            tagView.setColor3(mContext.getResources().getColor(R.color.tag2_color3));
            tagView.setContent("专题突破");
        } else if ("综合升华".equals(item.getKind())) {
            tagView.setColor1(mContext.getResources().getColor(R.color.tag3_color1));
            tagView.setColor2(mContext.getResources().getColor(R.color.tag3_color2));
            tagView.setColor3(mContext.getResources().getColor(R.color.tag3_color3));
            tagView.setContent("综合升华");
        } else if ("名校冲刺".equals(item.getKind())) {
            tagView.setColor1(mContext.getResources().getColor(R.color.tag4_color1));
            tagView.setColor2(mContext.getResources().getColor(R.color.tag4_color2));
            tagView.setColor3(mContext.getResources().getColor(R.color.tag4_color3));
            tagView.setContent("名校冲刺");
        }
        tagView.updatePaint();
    }

}
